<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('passengers', function (Blueprint $table) {
            $table->id();
            $table->uuid('user_id')->comment('用户id');
            $table->string('passenger_id')->comment('乘客id');
            $table->string('truename')->comment('乘客姓名');
            $table->unsignedTinyInteger('identity_type')->default(1)->comment('证件类型 1 身份证');
            $table->string('identity_code', 25)->comment('证件号');
            $table->string('birth_day', 8)->default('')->comment('生日');
            $table->unsignedTinyInteger('passenger_type')->comment('乘客类型 1 成人 2 学生 3 儿童');
            $table->string('mobile', 11)->comment('手机号');
            $table->unsignedTinyInteger('gender')->default(0)->comment('性别 0未知  1 男 2 女');
            $table->unsignedTinyInteger('verify_state')->default(2)->comment('核验状态 1 已核验 2 未核验');
            $table->unsignedTinyInteger('delete_state')->default(0)->comment('删除状态 1 已删除 0 正常');
            $table->timestamp('deleted_at')->nullable()->comment('删除时间');
            $table->string('invite_user_id')->default('')->comment('受邀用户id');
            $table->timestamps();
            $table->index(['user_id', 'delete_state'], 'idx_user');
            $table->index(['user_id', 'mobile'], 'idx_mobile');
            $table->index(['user_id', 'identity_code'], 'idx_identity');
            $table->unique(['user_id', 'identity_code', 'delete_state']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('passengers');
    }
};
